#!/bin/sh

#  _           _     
# | |         | |    
# | |__   ___ | |__  
# | '_ \ / _ \| '_ \ 
# | |_) | (_) | |_) |
# |_.__/ \___/|_.__/
# ===the builder===

# ==== Build System Configurations ====
# Program description (printf formatting)
ABOUT="No description was supplied.\n"
# Variables for building your program
NAME="example"
FLAGS="-static"
LIBS=""
BUILD="cc $NAME.c -o $NAME $FLAGS $LIBS"
# Cleaning command
CLEAN="rm -rf $NAME"
# Installation command
INST="cp $NAME /usr/local/bin"
# Uninstallation command
UNINST="rm -rf /usr/local/bin/$NAME"

# ==== Functions ====
help(){
	printf "\"./bob about\" - Writes information about the program to the screen\n"
	printf "\"./bob build\" - Builds the program\n"
	printf "\"./bob clean\" - Removes any compiled binaries\n"
	printf "\"./bob install\" - Builds the program, then installs it\n"
	printf "\"./bob uninstall\" - Uninstalls the program\n"
}
about(){
	printf "$ABOUT"
}
build(){
	printf "$BUILD\n"
	$BUILD
}
install(){
	printf "$INST\n"
	$INST
}
uninstall(){
	printf "$UNINST\n"
	$UNINST
}
clean(){
	printf "$CLEAN\n"
	$CLEAN
}
# ==== Argument Parsing Section ====
# When no argument is given
if [ -z $1 ];then
	help
	exit
fi
# When some argument is given
if [ $1 = "about" ];then
	about
	exit
fi
if [ $1 = "build" ];then
	build
	exit
fi
if [ $1 = "clean" ];then
	clean
	exit
fi
if [ $1 = "install" ];then
	install
	exit
fi
if [ $1 = "uninstall" ];then
	uninstall
	exit
fi
